﻿#region Copyright Notice
// 
// 
// Copyright (c) 2009-2010 Anindya Chatterjee
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// 
// 
// 
#endregion
using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace GCore
{
    /// <summary>
    /// The base Google Service feed class. Every Google Service feed must inherits this class.
    /// </summary>
    /// <typeparam name="TEntry">The type of Atom entry for this feed.</typeparam>
    /// <remarks>
    /// You must add the [XmlRoot("feed", Namespace = "http://www.w3.org/2005/Atom")] attribute at top of each
    /// service feed class extending GFeed&lt;TEntry&gt; class.
    /// </remarks>
    [XmlRoot("feed", Namespace = "http://www.w3.org/2005/Atom")]
    public class GFeed<TEntry> : GObject where TEntry : GEntry, new()
    {
        /// <summary>
        /// Gets and sets feed id.
        /// </summary>
        [XmlElement("id", Namespace = "http://www.w3.org/2005/Atom")]
        public string Id { get; set; }

        /// <summary>
        /// Gets and sets date for last update.
        /// </summary>
        [XmlElement("updated", Namespace = "http://www.w3.org/2005/Atom")]
        public DateTime Updated { get; set; }

        /// <summary>
        /// Gets and sets the title of the feed.
        /// </summary>
        [XmlElement("title", Namespace = "http://www.w3.org/2005/Atom")]
        public string Title { get; set; }

        /// <summary>
        /// Gets and sets the subtitle of the feeds (if any).
        /// </summary>
        [XmlElement("subtitle", Namespace = "http://www.w3.org/2005/Atom")]
        public string Subtitle { get; set; }

        /// <summary>
        /// Gets and sets the collection of links associated with the feed.
        /// </summary>
        [XmlElement("link", Namespace = "http://www.w3.org/2005/Atom")]
        public List<Link> Links { get; set; }

        /// <summary>
        /// Gets and sets the generator of the feed.
        /// </summary>
        [XmlElement("generator", Namespace = "http://www.w3.org/2005/Atom")]
        public Generator Generator { get; set; }

        /// <summary>
        /// Gets and sets the list of <see cref="GEntry"/> objects of the feed.
        /// </summary>
        [XmlElement("entry", Namespace = "http://www.w3.org/2005/Atom")]
        public List<TEntry> Entries { get; set; }

        /// <summary>
        /// Gets and sets the total results in the feed.
        /// </summary>
        [XmlElement("totalResults", Namespace = "http://a9.com/-/spec/opensearch/1.1/")]
        public string TotalResults { get; set; }

        /// <summary>
        /// Gets and sets the start index of the feed.
        /// </summary>
        [XmlElement("startIndex", Namespace = "http://a9.com/-/spec/opensearch/1.1/")]
        public string StartIndex { get; set; }
    }
}